package com.hailian.fintech.hlrenting_houseserver.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hailian.fintech.hlrenting_houseserver.entity.Tenant;
import com.hailian.fintech.hlrenting_houseserver.entity.TenantVo;
import com.hailian.fintech.hlrenting_houseserver.service.ITenantService;
import com.hailian.fintech.hlrenting_houseserver.vo.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wyt
 * @since 2020-05-21
 */
@RestController
@RequestMapping("/tenant")
public class TenantController {

    @Autowired
    private ITenantService tenantService;


    /***
     * 测试数据
     * @return
     */
    @RequestMapping("/select")
    public ResultEntity list(){
        List<Tenant> list = tenantService.list();
        return ResultEntity.ok("数据访问成功",list);
    }

    /***
     * 租客列表
     * @param pageNum
     * @param pageSize
     * @param vo
     * @return
     */
    @RequestMapping("/list")
    public ResultEntity getAll(@RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum, @RequestParam(value = "pageSize",defaultValue = "3")Integer pageSize,TenantVo vo){
        Page<TenantVo> page = new Page<>(pageNum,pageSize);
        System.out.println("---------------------"+vo.getDate1()+"====================="+vo);
        return ResultEntity.ok("数据成功访问",tenantService.selectObject(page,vo));
    }
}

